cmake_minimum_required(VERSION 3.10)

project(dal_rticonnextdds)

if(CMAKE_EXTRA_SYSTEM MATCHES QNX)
    add_definitions(-DRTI_QNX)
else()
    add_definitions(-DRTI_UNIX)
endif()

include_directories($ENV{NDDSHOME}/include)
include_directories($ENV{NDDSHOME}/include/ndds)
include_directories(${PROJECT_SOURCE_DIR}/include)
link_directories($ENV{RTI_LD_LIBRARY_PATH})

add_library(dal_rticonnextdds SHARED
    src/dal/identifier.cpp
    src/dal/config_loader.cpp
    src/dal/utils.c
    src/dal/allocator.c
    src/dal/version.cpp
    src/dal_entity/domain_participant.cpp
    src/dal_entity/topic.cpp
    src/dal_entity/publisher.cpp
    src/dal_entity/subscriber.cpp
    src/dal_entity/service.cpp
    src/dal_entity/client.cpp
    src/converter/StatusConverter.cpp
    src/converter/StatusMaskConverter.cpp
    src/converter/QosConverter.cpp
    src/converter/SampleInfoConverter.cpp
    src/converter/RetTypeConverter.cpp
    src/converter/InstanceHandleConverter.cpp
    src/converter/GuidConverter.cpp
    src/converter/LocatorKindConverter.cpp
    src/listener_impl/DomainParticipantListenerImpl.cpp
    src/listener_impl/PublisherListenerImpl.cpp
    src/listener_impl/SubscriberListenerImpl.cpp
    src/listener_impl/TopicListenerImpl.cpp
    src/listener_impl/DataWriterListenerImpl.cpp
    src/listener_impl/DataReaderListenerImpl.cpp
    src/entity_impl/DalDomainParticipantImpl.cpp
    src/entity_impl/DalPublisherImpl.cpp
    src/entity_impl/DalSubscriberImpl.cpp
    src/entity_impl/DalTopicImpl.cpp
    src/entity_impl/DalDataWriterImpl.cpp
    src/entity_impl/DalDataReaderImpl.cpp
    src/rtps/Guid.cpp
    src/utils/StringUtils.cpp
    src/utils/ParticipantMonitor.cpp
    src/utils/ParticipantGuidMap.cpp
    src/utils/EntityMappingManager.cpp
    src/config_manager/ConfigManager.cpp)

target_link_libraries(dal_rticonnextdds 
    dal_typesupport_rticonnextdds_depends dal_utils fastcdr pthread)

add_subdirectory(test)
add_subdirectory(TestCases)

install(TARGETS dal_rticonnextdds
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

get_property( dal_rticonnextdds GLOBAL PROPERTY dal_rticonnextdds_version )
set_property(
    TARGET dal_rticonnextdds
    PROPERTY VERSION ${dal_rticonnextdds_version}
)
target_compile_definitions(dal_rticonnextdds PRIVATE LIB_VERSION=\"Version:${dal_rticonnextdds_version}\")

